<?php
  require_once "../../Helpers/DbHelper.php";
  class EnrolmentRequirementController
  {
    private $d;
    private $sStudId;
    //
    public function __construct()
    {
      $this->d = new DbHelper();
    }
    public function setStudentId($id)
    {
      $this->sStudId = $id;
    }
    public function getStudentId()
    {
      return $this->sStudId;
    }
    private function getQuery($bIsSetter, $typeName, $value)
    {
      $s = "SELECT Id FROM EnrolmentRequirementTypes WHERE Name = $typeName";
      $t = $bIsSetter ?
           "UPDATE EnrolmentRequirements SET Value='$value' WHERE " .
           "StudentId = $this->getStudentId() AND TypeId = $s" :
           "SELECT Value FROM EnrolmentRequirements WHERE " .
           "StudentId = $this->getStudentId() AND TypeId = $s";
      return  $t;
    }
    private function getValue($query)
    {
      $r = $this->d->query($query);
      $o = mysql_fetch_result($r);
      return $o->Value;
    }
    //
    public function setHasOriginalReportCard($value)
    {
      $this->d->query($this->getQuery(true, "OriginalReportCard", $value));
    }
    public function getHasOriginalReportCard()
    {
      return $this->getValue($this->getQuery(false, "OriginalReportCard", null));
    }
    //
    public function setHasBirthCertificate($value)
    {
      $this->d->query($this->getQuery(true, "BirthCertificate", $value));
    }
    public function getHasBirthCertificate()
    {
      return $this->getValue($this->getQuery(false, "BirthCertificate", null));
    }
    //
    public function setHasGoodMoralCharacter($value)
    {
      $this->d->query($this->getQuery(true, "GoodMoralCertificate", $value));
    }
    public function getHasGoodMoralCharacter()
    {
      return $this->getValue($this->getQuery(false, "GoodMoralCharacter", null));
    }
    public function setHasBaptismalCertificate($value)
    {
      $this->d->query($this->getQuery(true, "BaptismalCertificate", $value));
    }
    public function getHasBaptismalCertificate()
    {
      return $this->getValue($this->getQuery(false, "BaptismalCertificate", null));
    }
    //
    public function setHasCarrierPicture($value)
    {
      $this->d->query($this->getQuery(true, "CarrierPicture", $value));
    }
    public function getHasCarrierPicture()
    {
      return $this->getValue($this->getQuery(false, "CarrierPicture", null));
    }
  }
?>